package io;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import main.Game;
import main.ThinGame;

public class NetworkWindow extends JFrame {
	private JButton host = new JButton("Host game");
	private JButton join = new JButton("Join game");
	private JLabel text = new JLabel("J-Sym Ship");
	
	public static void main(String[] args) {
		new NetworkWindow();
	}
	
	public NetworkWindow() {
		this.getContentPane().setLayout(new FlowLayout());
		host.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				Network n = new Network();
				Game g = new Game(1, n);
				setVisible(false);
			}
			
		});
		
		join.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String ip = JOptionPane.showInputDialog("Enter host ip: ");
				Network n = new Network(ip);
				ThinGame g = new ThinGame(2, n);
				setVisible(false);
			}
		});
		
		this.getContentPane().add(text);
		this.getContentPane().add(host);
		this.getContentPane().add(join);
		setSize(400, 100);
		show();
	}
}
